;; =============================================================================
;; statement class tree

(in-package :oali.core)

;; =============================================================================
;; base class for all the statements that have name that reflects
;; corresponding code entity
(defclass p-named-entity ()
  (
   ;; slot name
   (name :initarg :name
	 :initform (error "name is not specified")
	 :reader name)
   ))

;; =============================================================================
;; statement class that is root for all the other classes
(defclass p-statement ()
  (
   ;;parent				; parent statement (nil for module statements)
   attributes				; each statement shall have associated user-defined attributes
   ))

;; =============================================================================
;; module
(defclass p-module (p-statement p-named-entity)
  ())

;; =============================================================================
;; type declaration
(defclass p-type (p-statement)
  (
   ;; represents type's presenter (if any)
   (presenter :initform nil :accessor presenter)
   ))


;; =============================================================================
;; incomplete type (e.g. type that can be converted to different one)
(defclass p-type-proxy (p-type)
  (
   ;; target type
   (proxy-type :initform nil :accessor proxy-type)
   ))

;; =============================================================================
;; represents builtin type
(defclass p-type-builtin (p-type p-named-entity)
  (
   (size :initarg :size
	 :initform (error "size is not specified"))
   ))

;; =============================================================================
;; qualified - e.g. unsigned type
(defclass p-qualified-type (p-type)
  (
   (qualifier :initarg :qualifier
	      :initform (error "qualifier is not specified")
	      :reader qualifier)
   (inferior-type :initarg :inferior-type
		  :initform (error "inferior builtin type is not specified")
		  :reader inferior-type)
   ))

;; =============================================================================
;; struct/union types
(defclass p-complex-type-member (p-statement p-named-entity)
  (
   (member-type :initform (error "type is not specified") :initarg :type :reader member-type)
   bitspec				; FIXME: incomplete
   ))

;; =============================================================================
;; complex - struct/union type
(defclass p-type-complex (p-type p-named-entity)
  (
   (is-union :initform nil :initarg :is-union :reader is-union)
   (align :initform nil :initarg :align :reader align)
   (members :initform nil :initarg :members :reader members)
   presenter-member			; FIXME: incomplete
   ))

;; =============================================================================
;; enum type
(defclass p-type-enum (p-type p-named-entity)
  (
   members
   ))

;; =============================================================================
;; pointer type
(defclass p-type-pointer (p-type)
  (
   (pointee-type :initarg :pointee-type
		 :initform (error "pointee type is not specified")
		 :reader pointee-type)
   ))


;; =============================================================================
;; argument
(defclass p-argument (p-statement)
  (
   dir					; in or out or both
   type
   name
   ))

;; =============================================================================
;; function declaration
(defclass p-func (p-statement)
  (
   calling-convention
   location
   
   name
   arglist
   body
   ))
